package com.plugin.core.util;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取properties配置文件
 */
@Slf4j
public class PropertiesUtil {


    private static final Properties prop;

    static {
        prop = new Properties();
        try {
            prop.load(readRes("wxpay.properties"));
        } catch (IOException e) {
            log.error("exception",e);

        }
    }

    /**
     *
     */
    public static String getValueByKey(String key){
        return prop.getProperty(key);
    }


    /**
     * 读取文件并转成流
     * @param filePath 文件名
     */
    private static InputStream readRes(String filePath){
        return PropertiesUtil.class.getClassLoader().getResourceAsStream(filePath);
    }

}
